// 连接数据库文件
const mongoose = require('mongoose');

// 数据库连接地址
const DB_URL = 'mongodb://localhost:27017/qfyp';
// 连接数据库
mongoose.connect(DB_URL, { useNewUrlParser: true });

// 连接成功
mongoose.connection.on('connected', () => {
  console.log('connect success');
})
// 连接失败断开
mongoose.connection.on('disconnected', () => {
  console.log('connect disconnected');
})
// 连接出错
mongoose.connection.on('error', () => {
  console.log('connect error');
})

module.exports = mongoose
